package Saas_Exercises;

import java.util.Scanner;

public class Assignment04_Recursion {
//Ackermann Function 
	static int function(int x, int y) {

		if (x == 0) {

			return y + 1;
		} else if (y == 0) {

			return function(x - 1, 1);
		} else {
			return function(x - 1, function(x, y - 1));

		}

	}

	public static void main(String[] args) {
		System.out.println("Please enter your numbers here");
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		Assignment04_Recursion a4 = new Assignment04_Recursion();
		int final_return = a4.function(x, y);
		System.out.println(final_return);
	}
}

// Sample Input and Output:
// Input:
// 0 0
// Output:
// 1
// Input:
// 2 1
// Output:
// 5
// Input:
// 3 2
// Output:
// 29
